﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutomationTools.Procedimentos.Acao.Transformacao;

namespace AutomationTools.Procedimentos.Leitura.Helper
{
    public class InputSelect : RegexParseObject<Select>
    {
        public InputSelect(string id)
            : base(string.Format(@"<select[^<>]*?name=[""']?{0}['""]?.*?</select>", id))
        {
        }
    }

    [CanRegexParse]
    public class Select
    {
        [RegexParse(@"id=(?:[""']?([^\s'""]+)['""]?)", Grupo = 1)]
        public string Id { get; set; }

        [RegexParse(@"name=(?:[""']?([^\s'""]+)['""]?)", Grupo = 1)]
        public string Name { get; set; }

        [RegexParse(@"<option.*?</option>", IsArray = true)]
        public Option[] Options { get; set; }
    }

    [CanRegexParse]
    public class Option
    {
        [RegexParse(@"value=(?:[""']?([^\s'""]+)['""]?)", Grupo = 2)]
        public string Value { get; set; }
        [RegexParse(@"<option.*?>(.*?)</option>", Grupo = 1)]
        public string Text { get; set; }

        public bool Selected { get; set; }
    }
}
